<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" class="talk">
  <input type="button" class="btn" value="发送">
  <script>
    var talkEle = document.querySelector('.talk')
    var btnEle = document.querySelector('.btn')
    btnEle.onclick = function () {
      var talkVal = talkEle.value
      var reg = new RegExp('(卧槽)|(你妈)|(傻逼)|(卧槽)|(wc)|(sb)|(卧槽)|(我草)|(尼玛)|(逼)|(草)|(操)', 'ig')
      var res = talkVal.replace(reg, function (arg) {
        return '*'.repeat(arg.length)
      })
      talkEle.value = res
    }
  </script>
</body>

</html>